package com.teamclub.erp.scontrollers

import com.teamclub.erp.sforms.ProductInfoForm
import com.teamclub.erp.sservices.ProductListService
import com.teamclub.util.libs.Eithers
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.{PostMapping, RequestBody, RequestMapping, RestController}

/**
  * Created by ilkkzm on 17-9-11.
  */

@RestController("com.teamclub.erp.scontrollers.ProductListController")
@RequestMapping(Array("/erp"))
class ProductListController {
  @Autowired
  var service: ProductListService = _

  @PostMapping(Array("productdict"))
  def listarray = {
    service.listArray
  }

  @PostMapping(Array("productlist"))
  def list(@RequestBody form: ProductInfoForm) = {
    Eithers.toJson(service.list(form))
  }

  @PostMapping(Array("productadd"))
  def add(@RequestBody form: ProductInfoForm) = {
    Eithers.toJson(service.add(form))
  }

  @PostMapping(Array("productdel"))
  def del(@RequestBody form: ProductInfoForm) = {
    Eithers.toJson(service.del(form))
  }
}
